﻿<UserControl x:Class="BasicSkin.ElisVKView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:controls="clr-namespace:ElisVK.Controls;assembly=ElisVK"
             xmlns:ViewModels="clr-namespace:ElisVK.ViewModels;assembly=ElisVK" xmlns:AudioSources="clr-namespace:ElisVK.Data.AudioSources;assembly=ElisVK" mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="480">
    <Grid>
        <DockPanel x:Name="MainPage" LastChildFill="True">
            <DockPanel.Style>
                <Style TargetType="{x:Type DockPanel}">
                    <Setter Property="Visibility" Value="Hidden"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=CurrentPage}" Value="MainPage">
                            <Setter Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </DockPanel.Style>
            <DockPanel Margin="5" LastChildFill="False" DockPanel.Dock="Top">
                <controls:FilterTextBox Name="txtFilter" LabelText="Search" Margin="15,0,0,0" VerticalAlignment="Center"
                                        Filter="txtFilter_Filter"  HorizontalAlignment="Left" Width="125"
                                        Text="{Binding Path=SearchString, UpdateSourceTrigger=PropertyChanged}">
                </controls:FilterTextBox>
                <Button Margin="0" BorderThickness="1" Background="Transparent" DockPanel.Dock="Right"
                        ToolTip="Refresh" Command="{x:Static ViewModels:ElisVKViewModel.ButtonCommand}" CommandParameter="Refresh">
                    <Image Height="26" Margin="0" Source="Res\Refresh.png"/>
                </Button>
            </DockPanel>
            <DockPanel DockPanel.Dock="Bottom" LastChildFill="False">
                <Slider Margin="5,0,5,0" DockPanel.Dock="Top" HorizontalAlignment="Stretch" Maximum="1" Minimum="0" MinWidth="150"
                    Value="{Binding Path=PlayerPosition, NotifyOnSourceUpdated=True, Mode=TwoWay}" IsMoveToPointEnabled="True"></Slider>
                <Button Margin="5" BorderThickness="1" Background="Transparent" DockPanel.Dock="Left"
                        ToolTip="Previous" Command="{x:Static ViewModels:ElisVKViewModel.ButtonCommand}" CommandParameter="Previous">
                    <Image Height="26" Margin="0" Source="Res\Previous.png"/>
                </Button>
                <Button Margin="5" BorderThickness="1" Background="Transparent" DockPanel.Dock="Left"
                        ToolTip="Play/Pause" Command="{x:Static ViewModels:ElisVKViewModel.ButtonCommand}" CommandParameter="Play/Pause">
                    <Image Height="26" Margin="0">
                        <Image.Style>
                            <Style TargetType="{x:Type Image}">
                                <Setter Property="Source" Value="Res\Play.png"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=IsPlaying}" Value="True">
                                        <Setter Property="Source" Value="Res\Pause.png"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <Button Margin="5" BorderThickness="1" Background="Transparent" DockPanel.Dock="Left"
                        ToolTip="Next" Command="{x:Static ViewModels:ElisVKViewModel.ButtonCommand}" CommandParameter="Next">
                    <Image Height="26" Margin="0" Source="Res\Next.png"/>
                </Button>
                <Image Height="26" Margin="15,0,0,0" VerticalAlignment="Center" DockPanel.Dock="Left" Source="Res\Volume_1.png"/>
                <Slider VerticalAlignment="Center" Margin="5" Value="{Binding Path=Volume, NotifyOnSourceUpdated=True, Mode=TwoWay}" Maximum="1" Minimum="0"
                    DockPanel.Dock="Left" ToolTip="Volume" MinWidth="150" IsMoveToPointEnabled="True"/>
                <Image Height="26" VerticalAlignment="Center" DockPanel.Dock="Left" Source="Res\Volume_3.png"/>
                <Button Margin="5" BorderThickness="1" Background="Transparent" DockPanel.Dock="Left"
                        ToolTip="Shuffle" Command="{x:Static ViewModels:ElisVKViewModel.ButtonCommand}" CommandParameter="Shuffle">
                    <Image Height="26" Margin="0">
                        <Image.Style>
                            <Style TargetType="{x:Type Image}">
                                <Setter Property="Source" Value="Res\ShuffleOff.png"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=IsShuffleOn}" Value="True">
                                        <Setter Property="Source" Value="Res\ShuffleOn.png"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <Button Margin="5" BorderThickness="1" Background="Transparent" DockPanel.Dock="Right"
                        ToolTip="Settings" Command="{x:Static ViewModels:ElisVKViewModel.ButtonCommand}" CommandParameter="Settings">
                    <Image Height="26" Margin="0" Source="Res\Settings.png"/>
                </Button>
                <Button Margin="5" BorderThickness="1" Background="Transparent" DockPanel.Dock="Right"
                        ToolTip="Remove" Command="{x:Static ViewModels:ElisVKViewModel.RemoveCommand}" CommandParameter="{Binding Path=SelectedItems, ElementName=AudiosListBox}">
                    Remove
                    <!--<Image Height="16" Margin="3" Source="Res\Forward.png"/>-->
                </Button>
                <Button Margin="5" BorderThickness="1" Background="Transparent" DockPanel.Dock="Right"
                        ToolTip="Add" Command="{x:Static ViewModels:ElisVKViewModel.AddCommand}" CommandParameter="{Binding Path=SelectedItems, ElementName=AudiosListBox}" Content="Add">
                    <Button.Style>
                        <Style TargetType="{x:Type Button}">
                            <Setter Property="IsEnabled" Value="True"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Path=AudioSource}" Value="My_Music">
                                    <Setter Property="IsEnabled" Value="False"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                    <!--<Image Height="16" Margin="3" Source="Res\Forward.png"/>-->
                </Button>
            </DockPanel>
            <DockPanel LastChildFill="True">
                <TreeView x:Name="AudioSources" Margin="5" DockPanel.Dock="Left" ItemsSource="{Binding Path=AudioSources}"
                          SelectedItemChanged="AudioSources_SelectedItemChanged" MaxWidth="200">
                    <TreeView.ItemContainerStyle>                        
                        <Style TargetType="{x:Type TreeViewItem}">
                            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                            <Setter Property="FontWeight" Value="Normal" />
                            <Style.Triggers>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter Property="FontWeight" Value="Bold" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </TreeView.ItemContainerStyle>
                    <TreeView.Resources>
                        <ContextMenu x:Key="MyMusicContextMenu">
                            <ContextMenu.Items>
                                <MenuItem Name="Synchronize" Header="Synchronize" Command="{x:Static ViewModels:ElisVKViewModel.ButtonCommand}"
                                          CommandParameter="Synchronize"/>
                            </ContextMenu.Items>
                        </ContextMenu>
                        <DataTemplate DataType="{x:Type AudioSources:VKMyMusicAudioSource}">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Name}" ContextMenu="{StaticResource MyMusicContextMenu}"/>
                            </StackPanel>
                        </DataTemplate>
                        <HierarchicalDataTemplate DataType="{x:Type AudioSources:VKFriendsAudioSource}" ItemsSource="{Binding Children}">
                            <StackPanel Orientation="Horizontal">
                                <!--<Image Width="16" Height="16" Margin="3,0" Source="Images\Region.png" />-->
                                <TextBlock Text="{Binding Name}" />
                            </StackPanel>
                        </HierarchicalDataTemplate>
                        <HierarchicalDataTemplate DataType="{x:Type AudioSources:VKGroupsAudioSource}" ItemsSource="{Binding Children}">
                            <StackPanel Orientation="Horizontal">
                                <!--<Image Width="16" Height="16" Margin="3,0" Source="Images\Region.png" />-->
                                <TextBlock Text="{Binding Name}" />
                            </StackPanel>
                        </HierarchicalDataTemplate>
                        <HierarchicalDataTemplate DataType="{x:Type AudioSources:VKSubscriptionsAudioSource}" ItemsSource="{Binding Children}">
                            <StackPanel Orientation="Horizontal">
                                <!--<Image Width="16" Height="16" Margin="3,0" Source="Images\Region.png" />-->
                                <TextBlock Text="{Binding Name}" />
                            </StackPanel>
                        </HierarchicalDataTemplate>
                        <HierarchicalDataTemplate DataType="{x:Type AudioSources:VKBookmarksAudioSource}" ItemsSource="{Binding Children}">
                            <StackPanel Orientation="Horizontal">
                                <!--<Image Width="16" Height="16" Margin="3,0" Source="Images\Region.png" />-->
                                <TextBlock Text="{Binding Name}" />
                            </StackPanel>
                        </HierarchicalDataTemplate>
                    </TreeView.Resources>
                </TreeView>
                
                <ListBox x:Name="AudiosListBox" Margin="5" DockPanel.Dock="Right" ItemsSource="{Binding Path=Audios, NotifyOnSourceUpdated=True}"
                    SelectedItem="{Binding Path=SelectedAudio, NotifyOnSourceUpdated=True}"
                    SelectionMode="Extended" MouseDoubleClick="ListBox_MouseDoubleClick" IsSynchronizedWithCurrentItem="True" SelectionChanged="AudiosListBox_SelectionChanged">
                </ListBox>
            </DockPanel>
        </DockPanel>
        <DockPanel x:Name="SettingsPage" LastChildFill="True">
            <DockPanel.Style>
                <Style TargetType="{x:Type DockPanel}">
                    <Setter Property="Visibility" Value="Hidden"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=CurrentPage}" Value="SettingsPage">
                            <Setter Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </DockPanel.Style>
            <DockPanel LastChildFill="False" Margin="0,0,0,5" DockPanel.Dock="Bottom">
                <Button Margin="5" BorderThickness="1" Background="Transparent" DockPanel.Dock="Left"
                        ToolTip="Settings" Command="{x:Static ViewModels:ElisVKViewModel.ButtonCommand}" CommandParameter="MainPage">
                    <Image Height="26" Margin="0" Source="Res\Return.png"/>
                </Button>
                <Button Margin="5" BorderThickness="1" Background="Transparent" DockPanel.Dock="Right"
                        ToolTip="Settings" Command="{x:Static ViewModels:ElisVKViewModel.ButtonCommand}" CommandParameter="SaveSettings">
                    <Image Height="26" Margin="0" Source="Res\Save.png"/>
                </Button>
            </DockPanel>
            <TabControl Margin="5" DataContext="{Binding Path=Settings}">
                <TabControl.Items>
                    <TabItem Header="System hot Keys">
                        <DockPanel LastChildFill="False">
                            <CheckBox Content="Use hot keys" IsChecked="{Binding Path=UseHotKeys}"/>
                        </DockPanel>
                    </TabItem>
                    <TabItem Header="LastFM scrobbling">
                        <DockPanel LastChildFill="False">
                            <CheckBox Content="Use LastFM scrobbling" IsChecked="{Binding Path=UseScrobbling}"/>
                        </DockPanel>
                    </TabItem>
                </TabControl.Items>
            </TabControl>            
        </DockPanel>
    </Grid>
</UserControl>
